#include "label.h"
#include <QPoint>
#include <QDebug>
#include <mainwindow.h>
Label::Label(QWidget *parent) :
    QLabel(parent),fath(parent)
{
   qDebug()<<"start";
   qDebug()<<this->parent();
   //this->setEnabled(false);
}

Label::~Label()
{

}

void Label::mouseMoveEvent(QMouseEvent *event)
{
    if ( event->buttons() == Qt::LeftButton )
        {
            endPos = event->globalPos() - startPos;
            this->move(endPos);
    }
    //update();
   // QWidget::mouseMoveEvent(event);
    //update();
    event->ignore();
}

void Label::mousePressEvent(QMouseEvent *event)
{
    if ( event->button() == Qt::LeftButton )
        {
           // startPos = event->globalPos() - this->frameGeometry().topLeft();
            //Form *it=new Form(fath);
            //it->setGeometry(this->geometry());
            //it->setText("yfefefiefdsfasdfsdfsdaf");
            //it->show();
        }
}

void Label::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        delete this;
    }
}
